package com.mdd.admin.controller.image;

import com.mdd.admin.config.aop.Log;
import com.mdd.admin.service.image.IGoodsImageService;
import com.mdd.admin.validate.image.GoodsImageParam;
import com.mdd.admin.vo.image.GoodsImageDetailVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.validator.annotation.IDMust;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 服务轮播图管理
 */
@Deprecated
@RestController
@RequestMapping("api/image")
public class GoodsImageController {

    @Resource
    IGoodsImageService iGoodsImageService;

    /**
     * 服务轮播图详情
     *
     * @param id 主键ID
     * @return Object
     */
    @GetMapping("/detail")
    public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        GoodsImageDetailVo detail = iGoodsImageService.detail(id);
        return AjaxResult.success(detail);
    }

    /**
     * 服务轮播图新增
     *
     * @param goodsImageParam 参数
     * @return Object
     */
    @Log(title = "服务轮播图新增")
    @PostMapping("/add")
    public Object add(@Validated(value = GoodsImageParam.create.class) @RequestBody GoodsImageParam goodsImageParam) {
        iGoodsImageService.add(goodsImageParam);
        return AjaxResult.success();
    }

    /**
     * 服务轮播图编辑
     *
     * @param goodsImageParam 参数
     * @return Object
     */
    @Log(title = "服务轮播图编辑")
    @PostMapping("/edit")
    public Object edit(@Validated(value = GoodsImageParam.update.class) @RequestBody GoodsImageParam goodsImageParam) {
        iGoodsImageService.edit(goodsImageParam);
        return AjaxResult.success();
    }

    /**
     * 服务轮播图删除
     *
     * @param goodsImageParam 参数
     * @return Object
     */
    @Log(title = "服务轮播图删除")
    @PostMapping("/del")
    public Object del(@Validated(value = GoodsImageParam.delete.class) @RequestBody GoodsImageParam goodsImageParam) {
        iGoodsImageService.del(goodsImageParam.getId());
        return AjaxResult.success();
    }

}
